<!-- 本页面为点击申请售后跳转的页面 -->
<template>
	<view>
		<view>
			-------------添加订单已签收（已完成）状态的售后-------------
		</view>
		<view>
			---------------退货退款(非质量问题请勿申请)---------------
		</view>
		<view>
			<form @submit="formSubmit" @reset="formReset">
				
				<view class="uni-form-item uni-column">
					<view class="title">售后原因：</view>
					<input class="uni-input" name="input" v-model="shouhou.shReason" placeholder="售后原因(必填)" />
				</view>
				<view class="uni-form-item uni-column">
					<view class="title">售后备注：</view>
					<input class="uni-input" name="input" v-model="shouhou.shRemark" placeholder="售后备注" />
				</view>
				<view class="uni-btn-v">
					<button form-type="submit">提交售后</button>
					<button type="default" form-type="reset">重置清空</button>
				</view>
			</form>
		</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				shouhou:{id:"",shReason:"",shRemark:""}
			}
		},
		methods: {
			formSubmit: function(e) {
				if(this.shouhou.shReason==""){
					uni.showToast({
						title: '售后原因为必填项',
						icon:'error',
						duration: 2000
					});
					return;
				}
				console.log(this.shouhou);
				uni.request({
					url: 'api/order-server/shouhou/addShouhouForYi',
					data: 
						this.shouhou
					,
					header: {
						"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ6eU1hbmFnZSI6eyJpZCI6IjE4MjA3NzkzMTgxODg1NzY3NjgiLCJtYW5hZ2VBY2NvdW50IjoiY2oiLCJtYW5hZ2VOaWNrTmFtZSI6ImNqIn19.AI1W3jxpA1T1k438YI8weWTw_51jKU2uUQAjKKJ3Rig"
					},
					method:'POST',
					success: (res) => {
						console.log(res.data);
						if (res.data.code == 200) {
							uni.showToast({
								title: '申请售后成功',
								icon: 'success',
								duration: 2000
							});
							uni.navigateTo({
								url:'/pages/Shouhou/Shouhou'
							})
						}
					},
				
				});
			},
			
			queryAllShouhoutype(){
				//查询所有售后类型
				uni.request({
					
					url: 'api/order-server/shouhou/queryAllShouhouType',
					method: 'POST',
					header: {
						"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ6eU1hbmFnZSI6eyJpZCI6IjE4MjA3NzkzMTgxODg1NzY3NjgiLCJtYW5hZ2VBY2NvdW50IjoiY2oiLCJtYW5hZ2VOaWNrTmFtZSI6ImNqIn19.AI1W3jxpA1T1k438YI8weWTw_51jKU2uUQAjKKJ3Rig"
					},
					success: (res) => {
						//debugger
						if (res.data.code == 200) {
							console.log(res.data);
							this.shouhouTypeList = res.data.data;
						}
					}
				})
			},
			formReset: function(e) {
				console.log('清空数据')
				this.shouhou.shReason="";
				this.shouhou.shRemark="";
			},
		},
		onLoad(e) {
			console.log(e);
			this.shouhou.id=e.orderId;
		}
	}
</script>

<style>
	.uni-form-item .title {
		padding: 20rpx 0;
	}

	.uni-form-item .title {
		padding: 20rpx 0;
	}
</style>